#ifndef __TOCUTIL_H__
#define __TOCUTIL_H__

#include <ctime>
#include <cstdlib>
#include <iostream>
#include <cmath>

#include <GL/glut.h>

#include "toc.h"
#include "tocBody.h"
#include "tocHuman.h"
#include "tocGhoul.h"

const int TOC_W      = 1024;
const int TOC_H      = 1024;
const int TOC_STARTX = 0;
const int TOC_STARTY = 0;
const int MAP_W      = 2048;
const int MAP_H      = 2048;

enum GlutWheel {
	WHEEL_UP = 3,
	WHEEL_DOWN
};

typedef struct {
	GLfloat x;
	GLfloat y;
}TocPoint_t;

void drawTriangle(unsigned int color, float x, float y, 
		  float halfLength, float halfBreadth, float e);

std::vector<float> getCentroid(std::vector<TOCGhoul> &neighbors);

static inline int getRandomNum(void) {
	/* unsigned long seed = time(NULL); */
	/* srandom(seed); */

	return random();
}

static inline int getRandomDir(void) {
	return (getRandomNum() % 4);
}

static inline GLfloat getRandomCoordinate(void)
{
	int sign[2] = {-1, 1};

	return ((getRandomNum() % 1000) * 0.001 * (sign[getRandomNum() % 2]));
}

static inline GLfloat getRandomSeededCoordinate(unsigned int seed)
{
	int sign[2] = {-1, 1};
	srandom(seed);

	return ((random() % 1000) * 0.01 * (sign[random() % 2]));
}

#endif /* __TOCUTIL_H__ */
